
package com.roc.web.action.setting;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * @author Feng haitao
 *
 */
public class FrozenSearchCondition extends BaseSearchCondition {
	

	private String merNo;
	private String realName;
	private String settFlag;
	private String minDate;
	private String maxDate;
	private String orgCode;
	private String frozenFlag;
	

	

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		
		return "";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {
	    StringBuffer sb =new StringBuffer();
	    sb.append("select count(*) from t_transjnls_settle t,ESMIDINFO e where 1=1 and t.MERCHANTNO=e.mid and t.freezeflag='N' and t.settleflag in ('Y','H')");
//	    if (Constance.isNotEmpty(merNo)) {
//	    	sb.append(" and t.MERCHANTNO='"+merNo+"'");
//	    }
//	    if (Constance.isNotEmpty(realName)) {
//	    	sb.append(" and e.MER_NAME like '%"+realName+"%' ");
//	    }
//	    if (Constance.isNotEmpty(settFlag)) {
//	    	sb.append(" and t.SETTLEFLAG ='"+settFlag+"'");
//	    }
//	    if (Constance.isNotEmpty(minDate)) {
//	    	Date startDate=Constance.formateDate(minDate);
//	    	sb.append(" and t.SETTLEDATE>='"+startDate+"'");
//	    }
//	    if (Constance.isNotEmpty(maxDate)) {
//	    	Date endDate =Constance.formateDate(maxDate);
//	    	sb.append(" and t.SETTLEDATE<='"+endDate+"'");
//	    }
//	    if (Constance.isNotEmpty(orgCode)) {
//	    	sb.append(" and e.BELONG_BRANCH='"+orgCode+"'");
//	    }
	    
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
		
		return " select t.orderno,t.merchantno,t.merchantname,t.settledate,t.freezeflag,t.totalamt,t.totalnum,t.merchantfee,t.merchantsettleamt,t.settleflag,t.batchno,t.id from t_transjnls_settle t where 1=1 and t.freezeflag='N' and t.settleflag in ('Y','H')";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();

		
		if (Constance.isNotEmpty(merNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merchantno", merNo.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(settFlag)) {
			filedBeanList.add(new WhereHQLFieldBean("t.settleflag", settFlag.trim(), "=", false));
		}

		if (Constance.isNotEmpty(realName)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merchantname", realName.trim(),
					"LIKE", false, "ALL"));
		}
		if (Constance.isNotEmpty(orgCode)) {
			filedBeanList.add(new WhereHQLFieldBean("t.orgno", orgCode.trim()
					.trim(), "=", false));
		}
        
        if(Constance.isNotEmpty(minDate)&&Constance.isNotEmpty(maxDate)){
        	//Date startDate=Constance.formateDate(minDate);
        	//Date endDate =Constance.formateDate(maxDate);
        	String startDate = minDate.replace("-", "");
			String endDate = maxDate.replace("-", "");
        	filedBeanList.add(new WhereHQLFieldBean("t.settledate",startDate,
					">=", false));
        	filedBeanList.add(new WhereHQLFieldBean("t.settledate",endDate,
					"<=", false));
        }
     

		return filedBeanList;
	}





	public String getFrozenFlag() {
		return frozenFlag;
	}

	public void setFrozenFlag(String frozenFlag) {
		this.frozenFlag = frozenFlag;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	/**
	 * @return the realName
	 */
	public String getRealName() {
		return realName;
	}

	/**
	 * @param realName the realName to set
	 */
	public void setRealName(String realName) {
		this.realName = realName;
	}


	/**
	 * @return the minDate
	 */
	public String getMinDate() {
		return minDate;
	}

	/**
	 * @param minDate the minDate to set
	 */
	public void setMinDate(String minDate) {
		this.minDate = minDate;
	}

	/**
	 * @return the maxDate
	 */
	public String getMaxDate() {
		return maxDate;
	}

	/**
	 * @param maxDate the maxDate to set
	 */
	public void setMaxDate(String maxDate) {
		this.maxDate = maxDate;
	}

	public String getMerNo() {
		return merNo;
	}

	public void setMerNo(String merNo) {
		this.merNo = merNo;
	}



	public String getSettFlag() {
		return settFlag;
	}

	public void setSettFlag(String settFlag) {
		this.settFlag = settFlag;
	}



	public static void main(String[] args) {
		FrozenSearchCondition s=new FrozenSearchCondition();
		Object[] ids=new Object[]{"dxpeng","lisi","wangwu"};
		//s.setSuperiorId(1l);
		
		try {
			
			System.out.println(s.getFullSearchHQL(null));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
